home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Found / FWDebug / FWSymFil.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  3.6 KB  |  122 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWSymFil.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifdef FW_DEBUG
  11.  
  12. #ifndef FWENVDEF_H
  13. #include "FWEnvDef.h"
  14. #endif
  15.  
  16. #if !defined(FWSYMFIL_H) && defined(FW_DEBUG) && defined (FW_BUILD_WIN16)
  17. #define FWSYMFIL_H
  18.  
  19. #ifndef FWSTDDEFS_H
  20. #include "FWStdDef.h"
  21. #endif
  22.  
  23. #if !defined(__INC_WINDOWS)
  24. #include <windows.h>
  25. #endif
  26.  
  27. //========================================================================================
  28. // FW_CPrivWinSymFile:
  29. //
  30. // Interface to Windows format .SYM files.  They are generated from link .MAP
  31. // files by Microsoft MAPSYM tool and contain a list of publics in a module sorted
  32. // by segment and Offset.  We use .SYM files to produce better FW_DEBUG printouts.
  33. //========================================================================================
  34.  
  35. class FW_CPrivWinSymFile
  36. {
  37. public:
  38.     FW_CPrivWinSymFile(const char* pzFileName);
  39.     /* Tries to load a .SYM file defined by pzFileName.  If the load fails, no
  40.       fError is generated as SYM files are optional. */
  41.  
  42.     ~FW_CPrivWinSymFile(void);
  43.     /* Frees fMemory allocated for the symbol data storage. */
  44.  
  45.     FW_Boolean FindSymbol(unsigned short wSeg,
  46.                           unsigned short fOffset,
  47.                           unsigned short cbMaxLen,
  48.                           char* pzName);
  49.     /* Attempts to locate a symbol in the file.  wSeg is the ordinal segment
  50.       number in a Windows executable file and wOfs is the Offset within that
  51.       segment.  If succesfull, copies the name to pzName, cbMaxLen is the buffer
  52.       size. */
  53.  
  54. private:
  55.     void* fSymData;
  56.     
  57.     FW_CPrivWinSymFile(const FW_CPrivWinSymFile& symFile);
  58.     FW_CPrivWinSymFile& operator=(const FW_CPrivWinSymFile& symFile);
  59.         // Don't copy instances of this class.
  60. };
  61.  
  62.  
  63. //========================================================================================
  64. // FW_CPrivWinDebugModuleList:
  65. //
  66. // A class for obtaining symbolic info on Windows modules.  Useful for stack
  67. // walk and FW_DEBUG messages.
  68. //========================================================================================
  69.  
  70. class FW_CPrivWinDebugModuleList
  71. {
  72. public:
  73.     static void Initialize(void);
  74.     static void Terminate(void);
  75.  
  76.     static FW_Boolean FindSymbol(HANDLE fModule,
  77.                                  unsigned short wSeg,
  78.                                  unsigned short fOffset,
  79.                                     unsigned short cbMaxLen,
  80.                                     char* pzName);
  81.     /* Attempts to locate a symbol in a Windows module.  See comment for
  82.       FW_FW_CSymFile::FindSymbol above.  fModule is the module handle as returned
  83.       by TOOLHELP.DLL: do not pass instance handles! */
  84.       
  85.     static FW_Boolean GetModuleName(HANDLE fModule,
  86.                                     char* pzName);
  87.     /* Returns a short 8-char name of module identified by handle fModule. */
  88.  
  89.     enum
  90.     {
  91.         kMaxModules = 64,
  92.         kModuleNotFound = 128
  93.     };
  94.  
  95. private:
  96.     struct sOneModule
  97.     {
  98.         HANDLE fModule;
  99.         FW_CPrivWinSymFile* fSymFile;
  100.         char fModuleName[10];
  101.     };
  102.     
  103.     static sOneModule fModules[];
  104.     static unsigned short fNumberOfModules;
  105.     
  106.     static unsigned short FindModule(HANDLE fModule);
  107.     /* Searches the list for the module identified by fModule.  If the module is not
  108.       present yet, creates a new fEntryArray creates a FW_CPrivWinSymFile for it. Returns module index
  109.       on success, kModuleNotFound on failure */
  110.     
  111.     static unsigned short AddModule(HANDLE fModule);
  112.     /* Called by FindModule When the module fModule is not present in the list. */
  113.  
  114.     FW_CPrivWinDebugModuleList();
  115.         // Don't construct this object.
  116. };
  117.  
  118.  
  119. #endif // FWSYMFIL_H
  120.  
  121. #endif // FW_DEBUG
  122.